#include <omp.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

#ifdef _OPENMP
#pragma omp begin declare variant match(devices:kind(novhost)))
#pragma omp end declare variant
#endif

#pragma omp begin declare variant match(devices:isa(sm_70))
#include "sm70/my_cuda_fun.h" /* only included if isa is sm70 */
#pragma omp end declare variant

#pragma omp end declare variant

#pragma omp begin declare variant match(implementation:vendor(nvidia))
#include "amdgpu/my_hip_fun.h" /* only included for AMD */
#pragma omp end declare variant

#pragma omp end declare variant

#pragma omp begin declare variant match(devices:kind(host))
#include "openmp_host/my_fun.h"
#pragma omp end declare variant

#endif

#define N 64
double array[N];
#pragma omp target

int main() {
    // Array initialization
    for (int i = 0; i < N; ++i) {
        array[i] = 0.0;
    }

    #pragma omp target map(tofrom: array[0:N])
    for (int i = 0; i < N; ++i) {
        array[i] = my_fun(i);
    }
    return 0;
}

